package com.liuliu.controller.zua;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.liuliu.common.annotation.Log;
import com.liuliu.common.core.controller.BaseController;
import com.liuliu.common.core.domain.AjaxResult;
import com.liuliu.common.enums.BusinessType;
import com.liuliu.zua.domain.ZuaRecruitDetails;
import com.liuliu.zua.service.IZuaRecruitDetailsService;
import com.liuliu.common.utils.poi.ExcelUtil;
import com.liuliu.common.core.page.TableDataInfo;

/**
 * detailsController
 * 
 * @author liuliu
 * @date 2021-04-01
 */
@RestController
@RequestMapping("/zua/details")
public class ZuaRecruitDetailsController extends BaseController
{
    @Autowired
    private IZuaRecruitDetailsService zuaRecruitDetailsService;

    /**
     * 查询details列表
     */
    @PreAuthorize("@ss.hasPermi('zua:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZuaRecruitDetails zuaRecruitDetails)
    {
        startPage();
        List<ZuaRecruitDetails> list = zuaRecruitDetailsService.selectZuaRecruitDetailsList(zuaRecruitDetails);
        return getDataTable(list);
    }

    /**
     * 导出details列表
     */
    @PreAuthorize("@ss.hasPermi('zua:details:export')")
    @Log(title = "details", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZuaRecruitDetails zuaRecruitDetails)
    {
        List<ZuaRecruitDetails> list = zuaRecruitDetailsService.selectZuaRecruitDetailsList(zuaRecruitDetails);
        ExcelUtil<ZuaRecruitDetails> util = new ExcelUtil<ZuaRecruitDetails>(ZuaRecruitDetails.class);
        return util.exportExcel(list, "details");
    }

    /**
     * 获取details详细信息
     */
    @PreAuthorize("@ss.hasPermi('zua:details:query')")
    @GetMapping(value = "/{rDetailsId}")
    public AjaxResult getInfo(@PathVariable("rDetailsId") Long rDetailsId)
    {
        return AjaxResult.success(zuaRecruitDetailsService.selectZuaRecruitDetailsById(rDetailsId));
    }
    /**
     * 获取details详细信息根据recruitId
     */
    @GetMapping(value = "getDetailsByRecruitI/{recruitId}")
    public TableDataInfo getInfoByRecruitId(@PathVariable("recruitId") Long recruitId)
    {
        startPage();
        List<ZuaRecruitDetails> infoByRecruitId = zuaRecruitDetailsService.getInfoByRecruitId(recruitId);
        return getDataTable(infoByRecruitId);
    }

    /**
     * 新增details
     */
    @PreAuthorize("@ss.hasPermi('zua:details:add')")
    @Log(title = "details", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZuaRecruitDetails zuaRecruitDetails)
    {
        return toAjax(zuaRecruitDetailsService.insertZuaRecruitDetails(zuaRecruitDetails));
    }

    /**
     * 修改details
     */
    @PreAuthorize("@ss.hasPermi('zua:details:edit')")
    @Log(title = "details", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZuaRecruitDetails zuaRecruitDetails)
    {
        return toAjax(zuaRecruitDetailsService.updateZuaRecruitDetails(zuaRecruitDetails));
    }

    /**
     * 删除details
     */
    @PreAuthorize("@ss.hasPermi('zua:details:remove')")
    @Log(title = "details", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rDetailsIds}")
    public AjaxResult remove(@PathVariable Long[] rDetailsIds)
    {
        return toAjax(zuaRecruitDetailsService.deleteZuaRecruitDetailsByIds(rDetailsIds));
    }
}
